package com.qffx.moviebase.view;

import android.content.Intent;
import android.os.Bundle;
import android.os.CountDownTimer;
import android.widget.ImageView;
import android.widget.TextView;

import com.qffx.moviebase.R;
import com.qffx.moviebase.presenter.ADPresenter;
import com.qffx.moviebase.view.impl.BaseActivity;
import com.qffx.moviebase.view.impl.IADview;
import com.squareup.picasso.Picasso;

public class WelcomeActivity extends BaseActivity implements IADview {
    private ADPresenter presenter;
    private ImageView iv;
private TextView tv;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_welcome);
        init();

    }

    private void init() {
        presenter = new ADPresenter(this, this);
        iv = (ImageView) findViewById(R.id.wel_iv);
        tv= (TextView) findViewById(R.id.tv);
        presenter.initData();
        TimeCount();

    }

    @Override
    public void sendImageUrl(String url) {
        Picasso.with(this).load(url).into(iv);

    }
    //广告倒计时的方法
    public void TimeCount() {
        new CountDownTimer(4 * 1000, 1000) {
            @Override
            public void onTick(long l) {
               tv.setText("跳过广告 " + l / 1000 + " s");
            }

            @Override
            public void onFinish() {
                startActivity(new Intent(WelcomeActivity.this, MainActivity.class));
                finish();
            }
        }.start();
    }
}
